<template>
	<view class="box">
		<view class="flex" @click="show=true" style="border-radius: 6px;border: #fa1e8a dashed 1px;line-height: 42px;box-sizing: border-box;padding: 0 10px;">
			月经周期天数：<view style="margin-left: auto;">{{days}}</view>
		</view>
		<view class="f12 c6" style="margin-top: 10px;">
			如果您没有设置周期，系统会根据记录自动计算。恢复系统计算请选择0
		</view>
		<view>
			<view @click="setavg" class="button button1">保存</view>
		</view>
		<u-select v-model="show" :list="list" @confirm="confirm"></u-select></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					
				],
				show: false,
				days:0
			}
		},
		onLoad(e) {
			uni.setNavigationBarColor({
			    frontColor: '#000000',  
			    backgroundColor: '#ffffff',    
			})
			this.days=e.days
			for(let i=32;i--;){
				console.log(i)
				let arr={
						value: i,
						label: i
					}
				this.list.push(arr)
			}
		},
		methods: {
			async setavg(){
				let data={
					days:this.days
				}
				let res = await this.$u.api.avg(data)
				uni.showToast({
					title:'设置成功',
					icon:'none'
				})
				this.$u.vuex('vuex_avg',this.days)
				// this.navBack();
			},
			confirm(e){
				console.log(e)
				this.days=e[0].value
			},
		}
	}
</script>

<style>
.button1{
	width: 300px; line-height: 40px; text-align: center; margin: 10px auto 0px;
}
</style>
